<#include "../common/header.htm">
<div class="content-wrapper">
	<section class="content-header">
		<ol class="breadcrumb">
			<li><a href="${ctx}/">首页</a></li>
			<li class="active"><a href="#">我的工单</a></li>
		</ol>
	</section>
	<section class="content">
	   <div class="work-list-switch">
			<a href="${ctx}/workformlist/noreceive" <#if menu?? && menu=="noreceive">class="current"</#if> >待接收</a>
			<a href="${ctx}/workformlist/nodeal" <#if menu?? && menu=="nodeal">class="current"</#if> >待处理</a>
			<a href="${ctx}/workformlist/mywork/create" <#if menu?? && menu=="create">class="current"</#if> >我创建的</a>
			<a href="${ctx}/workformlist/mywork/trustees" <#if menu?? && menu=="trustees">class="current"</#if> >我经办的</a>
			<a href="${ctx}/workformlist/mywork/participants" <#if menu?? && menu=="participants">class="current"</#if> >我参与的</a>
	   </div>
	   <div class="box">
		<form action="${ctx}/workformlist/nodeal" method="get" id="listForm">
			<div class="box-header">
				<div class="row">
					<div class="col-sm-11">
							<div class="col-sm-2 right20" style="display: -webkit-box;">
								<label>类型：</label> 
								<select class="form-control" style="width: 150px;" name="businessType">
								   <option value="">请选择</option>
								   <#list businessTypeMap as key, value>
									   <#if params.businessType?exists && key == params.businessType>
											<option value="${key}" selected="selected">${value}</option>
										<#else>
											<option value="${key}">${value}</option>
										</#if>    
								   </#list>
								 </select>
							</div>
							<div class="col-sm-2" style="display: -webkit-box;">
								<label>关键字：</label> 
								<input name="keyword" type="text" class="form-control" placeholder="请输入编号/标题" value="${params.keyword!}"/>
							</div>
							<div class="col-sm-1" style="padding-left: 50px;">
								<input type="button" class="btn btn-default btn-search" onclick="workForm.query();" value="查询" />
							</div>
					</div>
				</div>
			</div>
			<div class="box-body">
				<table class="table table-hover table-bordered table-striped table-hide">
					<thead>
						<tr>
							<th>序号</th>
							<th>标题</th>
							<th>类型</th>
							<th>申请人</th>
							<th>计费</th>
							<th>期限（月）</th>
							<th>线路</th>
							<th>并发</th>
							<th>申请时间</th>
							<th>当前经办人</th>
							<th>进度</th>
							<th>操作</th>
						</tr>
					</thead>
					<tbody>
						<#list page.content as w>
						<tr>
							<td>${page.size*page.number+w_index+1}</td>
							<td title="${w.title!}">${w.title!}</td>
							<#if w.businessType?? && businessTypeMap["${w.businessType}"]?? >
								<td>${businessTypeMap["${w.businessType}"]!}</td>
							<#else>
								<td></td>
							</#if>
							<td>${w.createrName!}</td>
							<td>
								<#if w.clearingForm?? && clearingFormMap["${w.clearingForm}"]?? >
									${clearingFormMap["${w.clearingForm}"]!}
								<#else>
									--
								</#if>
							</td>
							<td>${w.clearingFormMonths!"--"}</td>
							<td>${w.lineNum!"--"}</td>
							<td>${w.concurrentNum!"--"}</td>
							<td>${w.createrTime?string("yyyy-MM-dd HH:mm:ss")}</td>
							<td><@mymacro.firstNotEmpty w.currentDealUserName! w.currentDealGroupName!></@mymacro.firstNotEmpty></td>
							<#if w.currentDealTag?? && tagMap["${w.currentDealTag}"]?? >
								<td>${tagMap["${w.currentDealTag}"]!}</td>
							<#else>
								<td></td>
							</#if>
							<td>
							   <#if w.createrId == loginUser.id>
							        <a href="javascript:void(0)" onclick="workForm.end(${w.lastRecordId})">结束</a>&nbsp;&nbsp;
							   </#if>
							    <a href="javascript:void(0)" onclick="workForm.todeal('${w.id}','${w.lastRecordId}','${w.currentDealTag}','${w.title}')">处理</a>&nbsp;&nbsp;
								<a href="${ctx}/workform/detail?workFormId=${w.id}&workFormRecordId=${w.lastRecordId}&title=${title}&url=${url}&currentDealTag=${w.currentDealTag}">详情</a>
							</td>
						</tr>
						</#list>
					</tbody>
				</table>
				<#include "../common/page.htm">
			</div>
						
		</form>
		</div>
	</section>
</div>
<script type="text/javascript">
var is_submit=false;
var workForm = {
	query : function() {
		$(":input[name='pageNumber']").val(0);
		$("form").submit();
	},
	todeal : function(id, lastRecordId, tag, workName) {
		if(is_submit){
			return;
		}
		is_submit=true;
		var title ="工单处理";
		var j = 0;
		base.getView({
			url:"${ctx}/workform/tohandle?workFormId="+id+"&lastRecordId="+lastRecordId+"&currentDealTag="+tag+"&workName="+encodeURIComponent(workName),
			success:function(result){
				bootbox.dialog({
					title:title,
					message:result,
					size:"large",
					closeButton : false,
					buttons:{
						cancel:{
							label:"取消",
							className:"btn btn-secondary",
							callback:function(){
								is_submit=false;
							}
						},
						sure:{
							label:"确定",
							className:"btn btn-primary",
							callback:function(){
								// $("#handle").submit();
								if (j != 0) {
									is_submit=false;
									return ;
								}
								j++;
								base.validAndAjaxSubmit($("#handle"), $("#listForm"), function () {
									j = 0;
								});
								return false;
							}
						}
					}
				})
			}
		})
	},
    end: function(workFormRecordId) {
    	if(is_submit){
			return;
		}
		is_submit=true;
        var title = '提示';
        base.getView({
            url:"${ctx}/workform/end?workFormRecordId="+workFormRecordId,
            success:function(result){
                bootbox.dialog({
                    title:title,
                    message:result,
                    size:"large",
                    closeButton : false,
                    buttons:{
                        cancel:{
                            label:"取消",
                            className:"btn btn-secondary",
							callback:function(){
								is_submit=false;
							}
                        },
                        sure:{
                            label:"确定",
                            className:"btn btn-primary",
                            callback:function(){
                                $("#confirm").submit();
                                return false;
                            }
                        }
                    }
                })
            }
        })
    }
}
	
</script>
<#include "../common/footer.htm">